class Solution {
public:
    int mySqrt(int x) 
    {
        if (x==0)
           return 0;
        double tmp=x,c=x;
        while(fabs(tmp*tmp-c)>1e-1)
        {
            tmp=0.5*tmp+0.5*c/tmp*1.0;
        }        
        return (int)tmp;
    }
};
